package com.py.framework.scheduler.job.factory;

import org.apache.commons.lang.StringUtils;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.alibaba.fastjson.JSON;
import com.py.framework.scheduler.common.JobConstants;
import com.py.framework.scheduler.job.Job;

/**
 * 默认的任务执行类
 * @author Leegern
 * @date   2018年5月7日
 */
public class DefaultJobFactory extends  AbstractJobFactory implements org.quartz.Job {
	
	/*
	 * (non-Javadoc)
	 * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
	 */
	@Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        String scheduleJob = (String) context.getMergedJobDataMap().get(JobConstants.SCHEDULER_NAME);
        if(StringUtils.isNotBlank(scheduleJob)){
            Job job = JSON.parseObject(scheduleJob, Job.class);
            invoke(job);
        }
    }
}